home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / libblas / rotmg.z / rotmg
Encoding:
Text File  |  2002-10-03  |  15.8 KB  |  342 lines

  1. ROTMG(3F)                                             Last changed: 11-2-98
  2.  
  3.  
  4. NNAAMMEE
  5.      SSRROOTTMMGG, DDRROOTTMMGG - Constructs a modified Givens plane rotation
  6.  
  7. SSYYNNOOPPSSIISS
  8.      Real
  9.  
  10.         CCAALLLL SSRROOTTMMGG ((_d ,, _d ,, _b ,, _b ,, _r_p_a_r_a_m))
  11.                       _1   _2   _1   _2
  12.      Double precision
  13.  
  14.         CCAALLLL DDRROOTTMMGG ((_d ,, _d ,, _b ,, _b ,, _r_p_a_r_a_m))
  15.                       _1   _2   _1   _2
  16. IIMMPPLLEEMMEENNTTAATTIIOONN
  17.      IRIX systems
  18.  
  19. DDEESSCCRRIIPPTTIIOONN
  20.      These routines compute the elements of a modified Givens plane
  21.      rotation matrix.
  22.  
  23.      These routines have the following arguments:
  24.  
  25.      _d         First diagonal element.  (input and output)
  26.       _1        SSRROOTTMMGG: Real.
  27.                DDRROOTTMMGG: Double precision.
  28.  
  29.                On input, this value is the first diagonal element of the
  30.                scaling matrix _D.  On the first call to the routine, this
  31.                value is typically 1.0.  Subsequent calls typically use the
  32.                value from the previous call.  On output, this value is the
  33.                first diagonal element of the updated scaling matrix _D''.
  34.  
  35.      _d         First diagonal element. (input and output)
  36.       _2        SSRROOTTMMGG: Real.
  37.                DDRROOTTMMGG: Double precision.
  38.  
  39.                On input, this is the first diagonal element of the scaling
  40.                matrix _D.  On the first call to the routine, this value is
  41.                typically 1.0.  Subsequent calls typically use the value
  42.                from the previous call.  On output, this value is the first
  43.                diagonal element of the updated scaling matrix _D''.
  44.  
  45.      _b         x-coordinate.  (input and output)
  46.       _1        SSRROOTTMMGG: Real.
  47.                DDRROOTTMMGG: Double precision.
  48.  
  49.                On input, this value is the _x-coordinate of the vector used
  50.                to define the angle of rotation, before scaling (multiplying
  51.                by the matrix _D).  On output, this value is the _x-coordinate
  52.                of the rotated vector, before scaling (multiplying by the
  53.                matrix _D'').
  54.  
  55.      _b         y-coordinate. (input)
  56.       _2        SSRROOTTMMGG: Real.
  57.                DDRROOTTMMGG: Double precision.
  58.  
  59.                On input, this value is the _y-coordinate of the vector used
  60.                to define the angle of rotation, before scaling (multiplying
  61.                by the matrix _D).  It is unchanged on output.
  62.  
  63.      _r_p_a_r_a_m    Real array of dimension 5.  (output)
  64.                SSRROOTTMMGG: Real array.
  65.                DDRROOTTMMGG: Double precision array.
  66.                This array contains rotation matrix information.  The
  67.                routine sets up the computed elements in _r_p_a_r_a_m from inputs
  68.                _d , _d , _b , and _b .
  69.                 _1   _2   _1       _2
  70.    SSttaannddaarrdd GGiivveennss RRoottaattiioonn
  71.      A standard Givens rotation (see SSRROOTTGG(3F)) is based on an orthogonal
  72.      matrix _G that rotates points on a Cartesian _x_y-coordinate plane.  To
  73.      calculate the rotation matrix, you must provide the angle of rotation
  74.      desired, or, equivalently, a vector (point) that lies along the angle
  75.      of rotation.  For a given planar point (_x , _y ), _G is formed so that:
  76.                                               _r   _r
  77.                _    _   _     _  _    _     _    _
  78.                | x' |   | c s |  | x  |   G | x  |
  79.                |    |   |     |  |  r |     |  r |
  80.                | 0  | = |-s c |  | y  | =   | y  |
  81.                |    |   |     |  |  r |     |  r |
  82.                -    -   -     -  -    -     -    -
  83.                         2     2
  84.      where _x' = sqrt (_x   + _y  ) .
  85.                        _r     _r
  86.      With this rotation matrix _G, you can then convert any number of
  87.      existing planar points to the new (rotated) _x_y-coordinate system.  For
  88.      _n points, the rotations would be as follows:
  89.  
  90.           _    _   _     _  _    _
  91.           | x  |   | c s |  | x  |
  92.           |  i |   |     |  |  i |
  93.           | 0  |<- |-s c |  | y  |
  94.           |  i |   |     |  |  i |
  95.           -    -   -     -  -    -
  96.  
  97.      for _i = 1, 2, ..., _n
  98.  
  99.    MMooddiiffiieedd GGiivveennss RRoottaattiioonn
  100.      The algorithm for these routines is based on the following
  101.      observation.  The rotation matrix _G can be factored into a _s_c_a_l_i_n_g
  102.      matrix (diagonal matrix) and _m_o_d_i_f_i_e_d rotation matrix _H, for which
  103.      either the diagonal or the off-diagonal elements are units (that is,
  104.      +1 or -1).  Thus, to perform _m modified (scaled) rotations on _n planar
  105.      points, requires only 2_n_m, rather than 4_n_m multiplications for the
  106.      standard rotation.
  107.  
  108.      Because you may want to perform several successive rotations, this
  109.      routine assumes that you have leftover scaling factors from your
  110.      previous modified Givens rotation; that is, the routine requires you
  111.      to input not only a planar rotation vector (_b , _b ) but also the
  112.      squares of the diagonal elements of the scali_n1g m_a2trix, _d  and _d .
  113.      The actual rotation vector is specified as follows:      _1      _2
  114.  
  115.           _    _   _                   _  _    _    1/2_    _
  116.           | _x_r |   | sqrt(_d_1)    0     |  | _b_1 |   _D   | _b_1 |
  117.           | _y_r | = |    0     sqrt(_d_2) |  | _b_2 | =     | _b_2 |
  118.           -    -   -                   -  -    -       -    -
  119.  
  120.      where _d_1 and _d_2 are the input scaling factors.
  121.  
  122.      Given these inputs, the routine generates a new modified rotation
  123.      matrix _H with units for either the diagonal or off-diagonal elements,
  124.      and new elements _d_1' and _d_2' for the new scaling factors, and rotated
  125.      but unscaled vector (_b_1', 0), with the following results:
  126.  
  127.             _    _      1/2_    _     1/2   _    _     1/2_         _ _    _
  128.           _G | _x_r |   _G _D   | _b_1 |   _D'    _H | _b_1 | = _D'   | _h_1_1 _h_1_2 | | _b_1 |
  129.             | _y_r | =       | _b_2 | =         | _b_2 |        | _h_2_1 _h_2_2 | | _b_2 |
  130.             -    -         -    -           -    -        -         - -    -
  131.                                                        1/2_     _   _    _
  132.                                                      _D'   | _b_1' |   | _x' |
  133.                                                    =      |  0  | = | 0  |
  134.                                                           -     -   -    -
  135.  
  136.      where:
  137.  
  138.           1/2
  139.           _D'   ( = diag {sqrt(_d_1'), sqrt(_d_2')} )
  140.  
  141.           uses the updated scaling factors _d '' and _d '', which are _d  and _d
  142.           on output.                        _1       _2              _1      _2
  143.           _H is stored in the output array argument _r_p_a_r_a_m;
  144.  
  145.  
  146.           _b_1' is stored as _b_1 on output.
  147.        1/2             1/2
  148.      _D''   _H equals _G _D    , nnoott _G, as implied earlier.  You must account
  149.      for the old scaling factors when calculating the new scaling factors.
  150.  
  151.      After calculating the matrix _H by using SSRROOTTMMGG/DDRROOTTMMGG, you can then
  152.      use it in SSRROOTTMM/DDRROOTTMM to convert points to the new coordinate system.
  153.  
  154. NNOOTTEESS
  155.    MMeeaanniinngg ooff tthhee OOuuttppuutt VVaalluueess
  156.      The output values are returned through arguments _d , _d , _b , and
  157.      _r_p_a_r_a_m.                                           _1   _2   _1
  158.  
  159.      The scaling factors _d  and _d  are updated with each call to the
  160.      routine.  Although SSRR_OO1TTMM/DDRROO_TT2MM does not need the updated factors, they
  161.      are needed in two other important contexts:
  162.  
  163.      * As input for subsequent calls to this routine.
  164.  
  165.      * As scaling factors for rotated but unscaled points (_x , _y ), which
  166.        are output from SSRROOTTMM./DDRROOTTMM.                        _i   _i
  167.  
  168.        In this second usage, the actual (scaled) points would be given by
  169.        (sqrt(_d_1)*_x(_i), sqrt(_d_2)*_y(_i)).  Doing this operation frequently on
  170.        all your points is counterproductive.  The main advantage of the
  171.        modified rotation algorithm is to reduce the number of operations.
  172.        If you fold in the scaling factors after each rotation, you are
  173.        performing the same number of operations as in the standard Givens
  174.        rotation.
  175.  
  176.      These two uses for the scaling factors are mutually exclusive; that
  177.      is, if you fold the scaling factors back into all your points, you no
  178.      longer need those factors for these routines.  After folding in the
  179.      scaling factors, and before the next call to SSRROOTTMMGG/DDRROOTTMMGG, reset _d
  180.      and _d  to 1.0.                                                     _1
  181.           _2
  182.      On output, _b  represents the new _x-coordinate after rotating (but
  183.      before scali_n1g) the rotation vector.  Although the _y-coordinate of
  184.      this vector is 0.0 (see the the previous discussion), the
  185.      corresponding value _b  is unchanged on output.
  186.                           _2
  187.      The output array argument _r_p_a_r_a_m specifies the format of matrix _H, and
  188.      it holds the nonunit values of _H.  This is the only output of these
  189.      routines that SSRROOTTMM/DDRROOTTMM requires.  Each element of _r_p_a_r_a_m has a
  190.      specific meaning, as follows:
  191.  
  192.      _r_p_a_r_a_m(1)  a flag parameter that specifies how the matrix is stored
  193.  
  194.                 = 0.0    Off-diagonal elements of _H are units.
  195.  
  196.                 = 1.0    Diagonal elements of _H are units.
  197.  
  198.                 = -1.0   Rescaling case (see the following subsection).
  199.  
  200.                 = -2.0   _H is the identity matrix; no rotation needed.
  201.  
  202.      _r_p_a_r_a_m(2)  = _h    if needed
  203.                    _1,_1
  204.      _r_p_a_r_a_m(3)  = _h    if needed
  205.                    _2,_1
  206.      _r_p_a_r_a_m(4)  = _h    if needed
  207.                    _1,_2
  208.      _r_p_a_r_a_m(5)  = _h    if needed
  209.                    _2,_2
  210.    CCaallccuullaattiinngg tthhee OOuuttppuutt VVaalluueess
  211.      The following presents the algorithm for calculating the output values
  212.      _d , _d , _b , and _r_p_a_r_a_m, based on the input values _d , _d , _b , and _b_2.
  213.      T_h1is _a2lgo_r1ithm is presented without explanation or _p1roo_f2.  _F1or a more
  214.      complete discussion of the modified Givens algorithm, see the papers
  215.      listed in the SEE ALSO section.
  216.  
  217.      CCaassee 11::  _b  = 0  (trivial case)
  218.                _2
  219.      In this case, no rotation is needed.  The flag value, _r_p_a_r_a_m(1), is
  220.      set to -2.0.  When passed to routine SSRROOTTMM/DDRROOTTMM, this flag indicates
  221.      that it should not do any rotations.
  222.  
  223.      On output from SSRROOTTMMGG/DDRROOTTMMGG, _d_1, _d_2, and _b_1 are unchanged.
  224.  
  225.      CCaassee 22::  | sqrt(_d_1)*_b_1 | > | sqrt(_d_2)*_b_2 |  (|_x_r| > |_y_r|)
  226.  
  227.      In this case, the diagonal elements of _H (_h    and _h   ) are set to
  228.      1.0 .  Thus, the _r_p_a_r_a_m values set on outpu_t1,_a1re as _f2,o_l2lows:
  229.  
  230.           _r_p_a_r_a_m(1) <-- 0.0
  231.           _r_p_a_r_a_m(3) <-- _h_2_1 = -_b_2/_b_1
  232.           _r_p_a_r_a_m(4) <-- _h_1,_2 = (_d_2*_b_2)/(_d_1*_b_1)
  233.  
  234.  
  235.      The output values of the scaling factors are as follows:
  236.  
  237.           _d_1 <-- _d_1' = _d_1/_u
  238.           _d_2 <-- _d_2' = _d_2/_u
  239.  
  240.  
  241.      where _u = det(_H) = 1 + (_d_2*_b_2*_b_2)/(_d_1*_b_1*_b_1) .
  242.  
  243.      The output value of _b  is as follows:
  244.                           _1
  245.           _b_1 <-- _b_1' = _b_1*_u
  246.  
  247.      If rescaling is needed, SSRROOTTMMGG/DDRROOTTMMGG will further modify these output
  248.      values before the end of the routine.  See case 4 later in this
  249.      subsection.
  250.  
  251.      CCaassee 33:: | sqrt(_d_1)*_b_1 | <= | sqrt(_d_2)*_b_2 | (|_x_r| <= |_y_r|)
  252.  
  253.      In this case, the off-diagonal elements of _H are units (to be
  254.      specific, _h_2,_1 = -1 and _h_1,_2 = 1).  Thus, the _r_p_a_r_a_m values set on
  255.      output are as follows:
  256.  
  257.           _r_p_a_r_a_m(1) <-- 1.0
  258.           _r_p_a_r_a_m(2) <-- _h_1,_1 = (_d_1*_b_1)/(_d_2*_b_2)
  259.           _r_p_a_r_a_m(5) <-- _h_2,_2 = _b_1/_b_2
  260.  
  261.      The output values of the scaling factors are as follows:
  262.  
  263.           _d_1 <-- _d_1' = _d_2/_u
  264.           _d_2 <-- _d_2' = _d_1/_u
  265.  
  266.      where _u = det(_H) = 1 + (_d_1*_b_1*_b_1)/(_d_2*_b_2*_b_2) .
  267.  
  268.      The output value of _b  is as follows:
  269.                           _1
  270.           _b_1 <-- _b_1' = _b_2*_u
  271.  
  272.      If rescaling is needed, SSRROOTTMMGG/DDRROOTTMMGG will further modify these output
  273.      values before the end of the routine.  See case 4.
  274.  
  275.      CCaassee 44::  Rescaling
  276.  
  277.      If the scaling factors become either very large or very small, the
  278.      scaling and rotation operations may lose a lot of accuracy; therefore,
  279.      each scaling factor from case 2 or case 3 is kept within the range:
  280.  
  281.           _g_a_m_m_a**(-2) <= | _d(_i)' | <= _g_a_m_m_a**2 ,  for _i = 1, 2
  282.  
  283.  
  284.      where _d(1)' = _d_1', _d(2)' = _d_2', and _g_a_m_m_a = 2.0**12 = 4096.0.
  285.  
  286.      At the end of case 2 or case 3 assignments, if either of the scaling
  287.      factors falls outside this range, this routine must rescale that
  288.      factor (and the corresponding elements of _H) to bring its size back
  289.      within the specified range.       48 - log2(_g_a_m_m_a) = 48 - 12 = 36 bits
  290.      (~ 10 decimal digits)
  291.  
  292.      Rescaling is performed as follows:
  293.  
  294.      If either _d_1 or _d_2 is 0, no rescaling is done;
  295.      otherwise, let
  296.           _q(_i) = int(log_base__g_a_m_m_a(sqrt(|_d(_i)'|)))
  297.                = int(log2(|_d(_i)'|)/24) ,             for _i = 1 , 2.
  298.  
  299.      Then the following is true:
  300.  
  301.           _q(_i) < 0 ,   if |_d(_i)'| < _g_a_m_m_a**2
  302.           _q(_i) = 0 ,   if _g_a_m_m_a**(-2) <= |_d(_i)'| <= _g_a_m_m_a**2
  303.           _q(_i) > 0 ,   if |_d(_i)'| > _g_a_m_m_a**2
  304.  
  305.  
  306.      Furthermore, |_q(_i)| represents the number of times _d(_i)' must be
  307.      multiplied (or divided) by _g_a_m_m_a**2 to return it to the proper range
  308.      of values.
  309.  
  310.      In this case, the _r_p_a_r_a_m values set on output are as follows:
  311.  
  312.           _r_p_a_r_a_m(1) <-- -1.0
  313.           _r_p_a_r_a_m(2) <-- _h_1,_1' = _h_1,_1*_g_a_m_m_a**_q(1)
  314.           _r_p_a_r_a_m(3) <-- _h_2,_1' = _h_2,_1*_g_a_m_m_a**_q(2)
  315.           _r_p_a_r_a_m(4) <-- _h_1,_2' = _h_1,_2*_g_a_m_m_a**_q(1)
  316.           _r_p_a_r_a_m(5) <-- _h_2,_2' = _h_2,_2*_g_a_m_m_a**_q(2)
  317.  
  318.  
  319.      The output values of the scaling factors are as follows:
  320.  
  321.           _d_1 <-- _d_1'' = _d_1'*_g_a_m_m_a**(-2*_q(1))
  322.           _d_2 <-- _d_2'' = _d_2'*_g_a_m_m_a**(-2*_q(2))
  323.  
  324.  
  325.      The output value of _b_1 is as follows:
  326.           _b_1 <-- _b_1'' = _b_1'*_g_a_m_m_a**_q(1)
  327.  
  328. SSEEEE AALLSSOO
  329.      RROOTT(3F), RROOTTGG(3F), RROOTTMM(3F)
  330.  
  331.      Gentleman, W. M., "Least Squares Computations by Givens
  332.      Transformations Without Square Roots," _J_o_u_r_n_a_l _o_f _t_h_e _I_n_s_t_i_t_u_t_e _f_o_r
  333.      _M_a_t_h_e_m_a_t_i_c_a_l _A_p_p_l_i_c_a_t_i_o_n_s 12 (1973),
  334.      pp. 329 - 336.
  335.  
  336.      Lawson, C., Hanson, R., Kincaid, D., and Krogh, F., "Basic Linear
  337.      Algebra Subprograms for Fortran Usage," _A_C_M _T_r_a_n_s_a_c_t_i_o_n_s _o_n
  338.      _M_a_t_h_e_m_a_t_i_c_a_l _S_o_f_t_w_a_r_e, 5 (1979),
  339.      pp. 308 - 325.
  340.  
  341.      This man page is available only online.
  342.